﻿class Ball {
	private var __instance:MovieClip;
	public var size:Number;
	public var vx:Number = 0;
	public var vy:Number = 0;
	function Ball(instance:MovieClip, size:Number) {
		__instance = instance;
		this.size = size;
		init();
	}
	private function init():Void {
		__instance.lineStyle(1, 0x000000, 100);
		var curveCount:Number = 16;
		var dAngle:Number = (2*Math.PI)/curveCount;
		var dCos:Number = Math.cos(dAngle);
		var dSin:Number = Math.sin(dAngle);
		var dAngle2:Number = dAngle/2;
		var dCos2:Number = Math.cos(dAngle2);
		var dSin2:Number = Math.sin(dAngle2);
		var x1:Number = size/2;
		var y1:Number = 0;
		__instance.moveTo(x1, y1);
		__instance.beginFill(0xff0000, 100);
		for (var i:Number = 0; i<curveCount; i++) {
			var x2:Number = dCos*x1-dSin*y1;
			var y2:Number = dCos*y1+dSin*x1;
			var xCon:Number = dCos2*x1-dSin2*y1;
			var yCon:Number = dCos2*y1+dSin2*x1;
			__instance.curveTo(xCon, yCon, x2, y2);
			x1 = x2;
			y1 = y2;
		}
		__instance.endFill();
	}
	public function get x():Number {
		return __instance._x;
	}
	public function set x(n:Number):Void {
		__instance._x = n;
	}
	public function get y():Number {
		return __instance._y;
	}
	public function set y(n:Number):Void {
		__instance._y = n;
	}
	public function get name():String {
		return __instance._name;
	}
	public function getInstance():MovieClip {
		return __instance;
	}
	public function getBounds():Object {
		return __instance.getBounds(__instance._parent);
	}
}
